<link href="../addons/jy_baojdai/custom/templates/mobile/style.css?v=201805251730" rel="stylesheet">
<style>
.fui-number .minus:before, .fui-number .plus:before {
	border-left: 0 solid #d9d9d9;
}
.fui-number .minus:after, .fui-number .plus:after {
	border-right: 0 solid #d9d9d9;
}
.fui-number:before {
	border-top: 0 solid #d9d9d9;
}
.fui-number:after {border-top: 0 solid #d9d9d9;}
.fui-number .num {
	color:#666;
}
.fui-number .num {
	color:#666;
}
.fui-number.small {
	height: 1.2rem;
	width: auto;
	line-height: 1.2rem;
}
.fui-number .minus, .fui-number .plus {
	z-index:0;
}
.fui-number.small .minus{
	color: {{main.syscolor || '#63BE72'}};
	padding-top:1px;
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
 .fui-number.small .plus {
	color: #fff;
	padding-top:1px;
	background: {{main.syscolor || '#63BE72'}};
	border: 1px solid {{main.syscolor || '#63BE72'}};
	border-radius:50%;
}
</style>
<div class='fui-page fui-page-current page-commission-myshop'>
    <div class='fui-content'>
	<div class="myshop-header">
	    <div class="image">
			<img ng-src="{{tomedia(pagedata.myshop.img) || '../addons/jy_baojdai/resource/images/myshoptop.jpg'}}"  />
	    </div>	   
	    <div class="menus">
		 <div class='shopname'>
	      {{pagedata.myshop.title || '未定义小店名称'}}
	    </div>
		 
		<div class="shoplogo">
		    <img ng-src="{{pagedata.myshop.logo || '../core/resource/images/nopic.jpg'}}"  />
		</div>
		<div class="nav" >
		    <p>{{pagedata.goodscount || 0}}</p>
		    <p>全部宝贝</p>
		</div>
		<div class="nav btn-qrcode"  ng-click="access_json('/qrcode//mid='+pagedata.mid)">
		    <p><i class="icon jinyunicon icon-qrcode"></i></p>
		    <p>二维码</p> 
		</div>
	    </div>
		
	</div>
	<div class="fui-searchbar">
		<div class="fui-cellone" style="padding:0;padding-top:0.6rem">
				 <div class="fui-cellone-info">
					<div class="search-input" style="height:1.6rem">
						<form action="javascript:return true">
						<i id="searchsub" class="icon icon-sousuo1 bold" ng-click="tool.get_list('jy_baojdai/myshop/list/mid='+scope.pagedata.mid,true)" style="line-height: 1.7rem;"></i>
						<input type="search" placeholder="请输入商品名称" class="search" ng-model="pagedata.params.keyword" style="height:1.6rem;border: 0;text-align: left; color: #999; font-size:0.6rem;background:#fff;border-radius: 1rem;" />
						</form>
					</div>
				 </div>
				 <div class="fui-cellone-remark noremark">
					<span style="margin-left:0.3rem;font-size: 0.75rem;" ng-click="tool.get_list('jy_baojdai/myshop/list/mid='+scope.pagedata.mid,true)">搜索</span>
				 </div>
		</div>
	</div>
	<div class="fixed-title" style="margin-top:0.5rem">
							 <span class="befirst spacing">
								 <span class="icon icon-icon-xiexiantiao" style="color:#efadb0"></span>
								 <span class="icon icon-icon-xiexiantiao" style="color:#e26d71"></span>
								 <span class="icon icon-icon-xiexiantiao" style="color:#d62f35"></span>
							 </span> 
							 <span class="title-text">小店推荐</span> 
							 <span class="spacing">
								 <span class="icon icon-icon-xiexiantiao" style="color:#d62f35"></span>
								 <span class="icon icon-icon-xiexiantiao" style="color:#e26d71"></span>
								 <span class="icon icon-icon-xiexiantiao" style="color:#efadb0"></span>
							 </span>
	</div>
	<div class="fui-goods-group block" id='container'>
	<div ng-repeat="g in pagedata.list" id="goodslist" class="fui-goods-item">
			<a ng-click="access_json('jy_weishop/goods.detail//frommyshop='+pagedata.myshop.mid+'&id='+g.id)">
						<div class="image" style="background-image:url('{{tomedia(g.image) || '../core/resource/images/nopic.jpg'}}')">
							<div ng-if="g.total<=0" class="salez" style="background-image: url('{{tomedia(pagedata.shopset.saleout)}}'); "></div>
						</div>
			</a>
			<div class="detail">
						<a ng-click="access_json('jy_weishop/goods.detail//frommyshop='+pagedata.myshop.mid+'&id='+g.id)">
							<div class="name">{{g.title}}</div>
						</a>
						<div class="price">
							<span class="text">￥{{g.price}}</span>
							<span ng-if="(!g.specs_list || g.specs_list.length < 1) && g.total>0" class="fui-number small" style="right:0">
									<span ng-if="g.carttotal>0" class="minus" ng-click="pagedata.minus(g)"><i class="icon icon-subtract" style="font-size:0.7rem"></i></span>
									<input ng-if="g.carttotal>0" class="num shownum" type="text" ng-model="g.carttotal" style="width:1rem" ng-change="pagedata.cart_refresh()"/>
									<span class="plus" ng-click="pagedata.plus(g)"><i class="icon icon-tianjia" style="font-size:0.7rem"></i></span>
							</span>
							<span ng-show="(!g.specs_list || g.specs_list.length < 1) && g.total==0" class="btn btn-sm btn-danger-o disabled" style="line-height:1rem;">已售馨</span>
							<span ng-show="g.specs_list.length > 0" class="btn btn-sm btn-danger-o order-finish" style="line-height:1rem" onclick="$('#selecttaocan').modal();" ng-click="pagedata.g=g;pagedata.nowgkey=$index;">选规格</span>
							<span ng-show="g.specs_list.length > 0 && g.carttotal" class="dot" style="display: block;">{{g.carttotal}}</span>
						</div>
						<div ng-if="g.commission_title" class="goods-tag"><div class="fui-tag fui-tag-danger fee-tag">{{g.commission_title}}￥{{g.commission_money}}</div></div>
			</div>
	</div>
	</div>
	<div ng-if="pagedata.loading" class='infinite-loading' style="text-align: center; color: #666;">
		<span class='fui-preloader'></span>
		<span class='text'> 正在加载...</span>
	</div>
	<div ng-if="!pagedata.loading && (!pagedata.list || pagedata.list.length<1)" class='content-empty' style="margin-top:0">
			<i class='icon icon-sousuo1'></i><br/>暂时没有任何商品
	</div>
	<div ng-include="sys_html('common/_copyright',true)"></div>
    </div>
	<div id='cover' ng-if="showcover ==1">
			<div class='fui-mask-m visible'></div>
			<div class='arrow'></div>
			<div class='content'>请点击右上角<br/>通过【收藏】<br/>方便下次浏览</div>
	</div>
</div>
<div id="selecttaocan" class="modal fade" tabindex="-1" style="z-index: 99999; display: none;">
					<div class="modal-dialog" style="width:90%;bottom:20%;left:5%;">
						<div class="modal-content" style="border-radius: 0.2rem;padding-top:1rem">
								<div aria-hidden="true" data-dismiss="modal" class="closebtn red" style="top:0.2rem;right:0.2rem"><i class="icon jinyunicon icon-close" style="font-size:1rem"></i></div>
								<div class="fixed-title">
									 <span class="befirst spacing">
										 <span class="icon icon-icon-xiexiantiao" style="color:#f9cc80"></span>
										 <span class="icon icon-icon-xiexiantiao" style="color:#e09c28"></span>
										 <span class="icon icon-icon-xiexiantiao" style="color:#d18301"></span>
									 </span> 
									 <span class="title-text">{{pagedata.g.title}}</span> 
									 <span class="spacing">
										 <span class="icon icon-icon-xiexiantiao" style="color:#d18301"></span>
										 <span class="icon icon-icon-xiexiantiao" style="color:#e09c28"></span>
										 <span class="icon icon-icon-xiexiantiao" style="color:#f9cc80"></span>
									 </span>
								 </div>
								 <div class="subtitle text-center" style="color:#999;font-size:0.6rem">
								 当前: {{pagedata.g.selespename}}
								 </div>
								 <div class="subtitle text-center" style="color:#999;font-size:0.6rem">
								    <span style="margin-right:0.2rem" ng-repeat="p in pagedata.g.post" ng-if="p.num>0">{{p.title}} * <span class="red">{{p.num}}</span></span>
								 </div>
								<div class="row margin0" style="padding-bottom:2.8rem">
									<div ng-repeat="(k,spec) in pagedata.g.specs_list" class="option-picker-cell option spec">
										<div class="fui-cell-group">
											<div class="fui-cell-title subtitle" style="color:#999;font-size:0.6rem">{{spec.title}}</div>
											<div class="fui-cell" style="padding-top:0.2rem">
												<div class="fui-cell-info">
													<span ng-repeat="item in spec.items" ng-class="{'jylabels jylabel-red-o':1,'active':pagedata.g.specid[k]==item.id}" style="line-height:0.8rem;padding: 0.1rem 0.6rem;" ng-click="pagedata.g.specid[k]=item.id;pagedata.get_optionsid();">{{item.title}}</span>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="fui-footer quick" style="height:2rem;padding:0;border-bottom-left-radius: 0.2rem;border-bottom-right-radius: 0.2rem;">
											<div class="quick-info" style="height:2rem;border-left: 0 solid #fff;">
													<p class="price" style="font-size:0.8rem;line-height:1.2rem">￥{{pagedata.g.options.price || 0.00}}/{{pagedata.g.unit||'份'}}<span ng-if="!pagedata.pluginset.noweight && pagedata.g.options.weight>0" style="color:#f2f2f2;font-size:0.55rem;font-weight:400">({{pagedata.g.options.weight}}kg)</span></p>
											</div>
											<div ng-show="pagedata.g.options.stock>0 && pagedata.g.post[pagedata.g.options.id].num<1" class="quick-submit" style="border-radius:0;height:2rem;margin: 0;font-size:0.65rem;line-height:1.6rem;padding-top:0.4rem" href="javascript:;" ng-click="pagedata.sp_plus(pagedata.g,$index);">
												<div class="bold" style="line-height:1">加入购物车</div>
												<div style="line-height:1">Add to Cart</div>
											</div>
											<div ng-show="pagedata.g.options.stock==0 && pagedata.g.post[pagedata.g.options.id].num<1" class="quick-submit" style="border-radius:0;height:2rem;margin: 0;font-size:0.65rem;line-height:1.6rem;padding-top:0.4rem;color:#f60">
												<div class="bold" style="line-height:1">已售馨</div>
												<div style="line-height:1">Is Sold</div>
											</div>
											<div ng-show="pagedata.g.post[pagedata.g.options.id].num>0"class="quick-submit" style="border-radius:0;height:2rem;margin: 0;font-size:0.8rem;line-height:1.2rem">
													<div class="quick-num open" style="margin-top:0.4rem">
														<div ng-click="pagedata.sp_minus()" class="minus icon icon-subtract bold" style="color: #000; background:none;border: 1px solid #000;font-size: 0.8rem;"></div>
														<div class="num red bold" style="color:#000">{{pagedata.g.post[pagedata.g.options.id].num}}</div>
														<div ng-click="pagedata.sp_plus()" class="plus icon icon-tianjia bold" style="border: 1px solid #000;font-size: 0.8rem;"></div>
													</div>
											</div>
								</div>
								<div class="clear"></div>
						</div>
					</div>
</div>
<div ng-include="sys_html('_footercart')"></div>
<script>
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});
scope.pagedata.mid=scope.pagedata.mid?scope.pagedata.mid:'';
scope.tool.get_list('jy_baojdai/myshop/list/mid='+scope.pagedata.mid,true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_baojdai/myshop/list/mid='+scope.pagedata.mid);
}
//减少
scope.pagedata.minus=function(g,iscart){
	var cartid=g.cartid
	var goodsid=g.id;
	var carttotal=g.carttotal;
	if(iscart){
		carttotal=g.total
		cartid=g.id
		goodsid=g.goodsid
	}
	if(carttotal<=0){
		return false;
	}
	scope.post_json('jy_weishop/member.cart/minus/',{'getlist':true,'id':cartid},function(res){
			if(iscart){
				g.total--
				for (j = 0; j < scope.pagedata.list.length; j++) {
						if(scope.pagedata.list[j].id==goodsid){
							scope.pagedata.list[j].carttotal=g.total
						}
				}
			}else{
			}
			if(res!='success'){
				g.carttotal--;
				scope.pagedata.carts=res.list
				scope.pagedata.dispatchprice=res.dispatchprice?res.dispatchprice:0;
				scope.pagedata.cart_refresh();
			}
	});
}
//增加
scope.pagedata.plus=function(g,iscart){
	var cartid=g.cartid
	var goodsid=g.id;
	var carttotal=g.carttotal;
	if(iscart){
		carttotal=g.total
		goodsid=g.goodsid
		cartid=g.id
		if(g.optionid>0){
			if(carttotal>=g.options.stock){
				scope.message('不能再添加了，已超过库存！','error');
				return false;
			}
		}else{
			if(carttotal>=g.goodstotal){
				scope.message('不能再添加了，已超过库存！','error');
				return false;
			}
		}
	}else{
		g.optionid=0;
		if(carttotal>=g.total){
			scope.message('不能再添加了，已超过库存！','error');
			return false;
		}
	}	
	scope.post_json('jy_weishop/member.cart/addtocart/',{'getlist':true,'goodsid':goodsid,'optionid':g.optionid},function(res){
			if(iscart){
				g.total++
				for (j = 0; j < scope.pagedata.list.length; j++) {
						if(scope.pagedata.list[j].id==goodsid){
							scope.pagedata.list[j].carttotal=g.total
						}
				}
			}else{
				if(res.cartid>0){
					g.cartid=res.cartid;
				}
			}
			if(res!='success'){
				g.carttotal++;
				scope.pagedata.carts=res.list
				scope.pagedata.dispatchprice=res.dispatchprice?res.dispatchprice:0;
			}
			scope.pagedata.cart_refresh();
	});
}
//减少
scope.pagedata.sp_minus=function(){
	var g =scope.pagedata.g;
	if(g.carttotal<=0){
		return false;
	}
	scope.post_json('jy_weishop/member.cart/minus/',{'getlist':true,'id':g.cartid,'optionid':g.options.id},function(res){
			g.carttotal--;
			if(g.post[g.options.id].num<=0){
				return false;
			}
			scope.pagedata.dispatchprice=res.dispatchprice?res.dispatchprice:0;
			scope.pagedata.carts=res.list
			g.post[g.options.id].num--;
			scope.pagedata.list[scope.pagedata.nowgkey]=g
			scope.pagedata.cart_refresh();
			
	});
}
//增加
scope.pagedata.sp_plus=function(){
	var g =scope.pagedata.g;
	if(g.carttotal>=g.options.stock){
		scope.message('不能再添加了，已超过库存！','error');
		return false;
	}
	scope.post_json('jy_weishop/member.cart/addtocart/',{'getlist':true,'goodsid':g.id,'optionid':g.options.id},function(res){			
			if(res!='success'){
				g.carttotal++;
				g.post[g.options.id].num++;
				scope.pagedata.dispatchprice=res.dispatchprice?res.dispatchprice:0;
				if(res.cartid>0){
					g.cartid=res.cartid;
				}
				scope.pagedata.carts=res.list
			}
			scope.pagedata.list[scope.pagedata.nowgkey]=g
			scope.pagedata.cart_refresh();
	});
}
//选择
scope.pagedata.get_optionsid=function(){
	var specid = scope.pagedata.g.specid;
	specid = specid.join('_');
	scope.post_json('jy_weishop/goods.detail/get_optionsid/',{'goodsid':scope.pagedata.g.id,'specid':specid,'isdish':1},function(res){
			var optionsid=res.options.id;
			scope.pagedata.g.options=res.options;
			scope.pagedata.g.selespename=res.selespename;
			if(!scope.pagedata.g.post[optionsid]){
				scope.pagedata.g.post[optionsid]={}
				scope.pagedata.g.post[optionsid]={
					'num':scope.pagedata.g.post[optionsid].num?scope.pagedata.g.post[optionsid].num:res.carttotal,
					'title':res.selespename,
				}
			}
			scope.$evalAsync();
	});
}
</script>